import { ServerOptions } from "vite";

export default function createVitePlugins(env: Record<string, string>): ServerOptions | undefined {
  return {
    port: 8083,
    host: true,
    open: true,
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy http://172.31.29.38:8080 http://10.0.23.26:31242 https://hi-clip-test.ssc-hn.com/hiclipapi
      [env.VITE_APP_BASE_API]: {
        // target: 'http://172.31.24.230:8080', //官灵本地
        // target: "http://172.31.29.82:8000", //润哥本地
        // target: "https://hi-clip-test.ssc-hn.com/hiclipapi", //测试
        // target: 'https://hi-clip-uat.ssc-hn.com/hiclipapi', // uat环境
        // target: 'https://hi-clip-test.ssc-hn.com/hiclipapi', // 测试环境
        target: 'http://10.0.70.14:30808', // 测试环境
        changeOrigin: true,
        rewrite: p => p.replace(new RegExp(`^${env.VITE_APP_BASE_API}`), "")
      }
    }
  };
}
